Skip to content

⚡ Bolt: Optimize export foreign key lookups by using parsed handles - #786

Closed
seonghobae wants to merge 13 commits into
mainfrom
jules-perf-handle-lookup-14142744112914767576
Closed

⚡ Bolt: Optimize export foreign key lookups by using parsed handles#786
seonghobae wants to merge 13 commits into
mainfrom
jules-perf-handle-lookup-14142744112914767576

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Outcome

Foreign-key export now decodes bounded React Flow handle identifiers once and validates the decoded names through node-level column indexes. Repeated edges no longer rescan or re-encode every column.

Safety and correctness

  • rejects absent, oversized, malformed, partial-hex, and invalid Unicode code-point handles;
  • preserves quoted, Unicode, and explicitly supported empty-column names;
  • validates every decoded source/target column against the exact node before emitting it;
  • keeps the existing metadata-first and primary-key fallback behavior;
  • stores no attacker-controlled values in module-global caches.

Test-first evidence

The new repeated-edge regression failed on the predecessor implementation with 203 column-name reads against the <20 bound. After node-level indexing:

  • focused handle lookup and consolidated encoder edge cases: 16 passed locally; exact-head CI covers the retained parser suite;
  • full frontend suite: 28 files / 200 tests passed;
  • frontend typecheck: passed;
  • production build: passed.

Local verification used Node 24.14 while the package declares Node 26; repository CI remains authoritative for the supported runtime.

Merge boundary

Exact current head: 3cb4319c7050a4a32c464f751e837b0a23bfeedd.

Merge only after current-head CI/security checks, zero valid unresolved findings, and a qualifying independent non-author approval satisfy repository policy. Synthetic-merge, predecessor-head, status-only, queued, or rate-limited evidence is not accepted.

@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

핸들 ID에서 컬럼명을 직접 복원하는 parseColumnNameFromHandle을 추가했습니다. FK 엣지 내보내기는 디코딩된 컬럼이 노드에 존재할 때 이를 사용하고, 그렇지 않으면 기존 fallback을 사용합니다. 파서 동작 테스트도 추가했습니다.

Changes

FK 핸들 디코딩

Layer / File(s) Summary
핸들 파서와 검증
frontend/src/erd/handleUtils.ts, frontend/src/erd/handleUtils.test.ts
src-tgt- 핸들에서 컬럼명을 복원하는 parseColumnNameFromHandle을 추가했습니다. 빈 입력, 잘못된 형식, 잘못된 인코딩의 반환값을 테스트합니다.
FK 내보내기 통합
frontend/src/erd/export.ts, .jules/bolt.md
FK 엣지 처리에서 핸들 ID를 직접 파싱합니다. 복원된 컬럼이 노드에 존재할 때 사용하고, 유효하지 않으면 기존 PK 기반 fallback을 사용합니다. 최적화 지침을 추가했습니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 export의 외래 키 조회를 파싱된 핸들로 최적화하는 주요 변경 사항을 정확하고 간결하게 설명합니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jules-perf-handle-lookup-14142744112914767576

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread frontend/src/erd/export.ts Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.jules/bolt.md:
- Around line 80-82: 엣지별 노드 컬럼 확인이 현재 .some 순회로 선형 탐색을 수행하므로 설명의 O(1) 주장과 구현이
일치하지 않습니다. FK 엣지 조회 로직에서 컬럼명을 담은 Set 인덱스를 먼저 구성하고, 각 조회가 해당 Set을 사용하도록 변경하십시오.
인덱스를 추가하지 않는 경우에는 선형 존재 확인이 유지된다는 내용으로 복잡도 설명을 갱신하십시오.

In `@frontend/src/erd/export.ts`:
- Around line 75-84: The edge-processing logic in frontend/src/erd/export.ts
lines 75-84 must replace per-edge columns.some checks with node-level Set
indexes built before the edge loop, then validate parsed source and target
columns using Set.has for O(1) lookup. Update .jules/bolt.md lines 80-82 to
document O(1) column lookup only after this Set-based indexing is implemented.
- Around line 75-88: Update the source and target handle checks in
fkColumnsForEdge to accept empty column names by testing parsedSource and
parsedTarget against null rather than truthiness, and use !== undefined for the
final resolved-column existence checks. Add focused fkColumnsForEdge tests
covering c-empty handles and preserving fallback behavior when handles cannot be
resolved.

In `@frontend/src/erd/handleUtils.ts`:
- Around line 33-40: Update the decoding logic around the visible split/map flow
in handleUtils so every token is validated as a complete hexadecimal code point
before calling parseInt; reject any token containing non-hex characters by
returning null, while preserving valid decoding and existing error handling. Add
a focused test covering encoded input such as src-c-0069junk-0064 and assert
that decoding returns null.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 039ce735-14df-4d2f-9c62-0da4c045d3f0

📥 Commits

Reviewing files that changed from the base of the PR and between 72afe6d and 80fc839.

⛔ Files ignored due to path filters (1)
  • frontend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .jules/bolt.md
  • frontend/src/erd/export.ts
  • frontend/src/erd/handleUtils.test.ts
  • frontend/src/erd/handleUtils.ts

Comment thread .jules/bolt.md
Comment thread frontend/src/erd/export.ts Outdated
Comment thread frontend/src/erd/export.ts Outdated
Comment thread frontend/src/erd/handleUtils.ts Outdated

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by draft #700 at exact head f9aa9d691adfae3865566a76e813a31c56a1c52b. The canonical lane implements the same node/column indexed DDL lookup plus stricter role-aware lowercase handle validation, authoritative supplied-handle fail-closed behavior, Prisma and data-dictionary parity, malformed/wrong-role/unknown-column/collision regressions, authoritative doctoring, and terminal-success exact-head CI/security gates. This branch remains unmerged; no predecessor evidence transfers.

@seonghobae seonghobae closed this Aug 11, 2026
@google-labs-jules

Copy link
Copy Markdown

Closing as superseded by draft #700 at exact head f9aa9d691adfae3865566a76e813a31c56a1c52b. The canonical lane implements the same node/column indexed DDL lookup plus stricter role-aware lowercase handle validation, authoritative supplied-handle fail-closed behavior, Prisma and data-dictionary parity, malformed/wrong-role/unknown-column/collision regressions, authoritative doctoring, and terminal-success exact-head CI/security gates. This branch remains unmerged; no predecessor evidence transfers.

Understood. Acknowledging that this work is now obsolete and stopping work on this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant